/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JanelaPrincipal.java
 *
 * Created on 11/05/2011, 16:49:31
 */

package gui;

import dominio.Usuario;

/**
 *
 * @author igo
 */
public class JanelaPrincipal extends javax.swing.JFrame implements JanelaCadastro{

    
    /** Creates new form JanelaPrincipal */
    public JanelaPrincipal() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        rotuloOla = new javax.swing.JLabel();
        rotuloLogin = new javax.swing.JLabel();
        botaoAluno = new javax.swing.JButton();
        botaoFuncionario = new javax.swing.JButton();
        botaoUsuario = new javax.swing.JButton();
        labelImagemPrincipal = new javax.swing.JLabel();
        labelUsuario = new javax.swing.JLabel();
        labelFuncionario = new javax.swing.JLabel();
        labelAluno = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("SisApae");
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setIconImages(null);
        setResizable(false);

        rotuloOla.setText("Ola,");

        rotuloLogin.setText("Usuario");

        botaoAluno.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/aluno.png"))); // NOI18N
        botaoAluno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoAlunoActionPerformed(evt);
            }
        });

        botaoFuncionario.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/professor.png"))); // NOI18N
        botaoFuncionario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoFuncionarioActionPerformed(evt);
            }
        });

        botaoUsuario.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/usuario.png"))); // NOI18N
        botaoUsuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoUsuarioActionPerformed(evt);
            }
        });

        labelImagemPrincipal.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/Imagem APAE m.jpg"))); // NOI18N

        labelUsuario.setText("Usuário");

        labelFuncionario.setText("Funcionário");

        labelAluno.setText("Aluno");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(rotuloOla, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(rotuloLogin, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(labelImagemPrincipal, javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(layout.createSequentialGroup()
                                            .addComponent(botaoAluno, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGap(64, 64, 64)
                                            .addComponent(botaoFuncionario, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                            .addComponent(labelFuncionario)
                                            .addGap(85, 85, 85)))
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(botaoUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGroup(layout.createSequentialGroup()
                                            .addGap(25, 25, 25)
                                            .addComponent(labelUsuario)))))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(56, 56, 56)
                        .addComponent(labelAluno)))
                .addContainerGap(41, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rotuloOla)
                    .addComponent(rotuloLogin))
                .addGap(18, 18, 18)
                .addComponent(labelImagemPrincipal)
                .addGap(20, 20, 20)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelAluno)
                    .addComponent(labelUsuario)
                    .addComponent(labelFuncionario))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(botaoFuncionario, 0, 0, Short.MAX_VALUE)
                    .addComponent(botaoAluno, 0, 0, Short.MAX_VALUE)
                    .addComponent(botaoUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void botaoFuncionarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoFuncionarioActionPerformed
        controlador.cadastrarFuncionario();
    }//GEN-LAST:event_botaoFuncionarioActionPerformed

    private void botaoUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoUsuarioActionPerformed
        controlador.cadastrarUsuario();
    }//GEN-LAST:event_botaoUsuarioActionPerformed

    private void botaoAlunoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoAlunoActionPerformed
        controlador.cadastrarAluno();
    }//GEN-LAST:event_botaoAlunoActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new JanelaPrincipal().setVisible(true);
            }
        });
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoAluno;
    private javax.swing.JButton botaoFuncionario;
    private javax.swing.JButton botaoUsuario;
    private javax.swing.JLabel labelAluno;
    private javax.swing.JLabel labelFuncionario;
    private javax.swing.JLabel labelImagemPrincipal;
    private javax.swing.JLabel labelUsuario;
    private javax.swing.JLabel rotuloLogin;
    private javax.swing.JLabel rotuloOla;
    // End of variables declaration//GEN-END:variables
    private ControladorPrincipal controlador;

    public void setControlador(Controlador controlador) {
        this.controlador = (ControladorPrincipal) controlador;
    }

    public void preparaTela() {
        Usuario u = (Usuario) controlador.getObject();
        rotuloLogin.setText(u.getLogin());
    }

    public void setVisivel(Boolean visivel) {
        super.setVisible(visivel);
    }
}
